const bcrypt = require('bcryptjs');

module.exports = {
    // excel 时间转换
    getFormatDate_XLSX:  (serial) =>{
        var utc_days = Math.floor(serial - 25569);
        var utc_value = utc_days * 86400;
        var date_info = new Date(utc_value * 1000);
        var fractional_day = serial - Math.floor(serial) + 0.0000001;
        var total_seconds = Math.floor(86400 * fractional_day);
        var seconds = total_seconds % 60;
        total_seconds -= seconds;
        var hours = Math.floor(total_seconds / (60 * 60));
        var minutes = Math.floor(total_seconds / 60) % 60;
        var d = new Date(date_info.getFullYear(), date_info.getMonth(), date_info.getDate(), hours, minutes, seconds);
        var add0 = (m) => m < 10 ? '0' + m : m;
        var YYYY = d.getFullYear();
        var MM = add0(d.getMonth() + 1);
        var DD = add0(d.getDate());
        var hh = add0(d.getHours());
        var mm = add0(d.getMinutes());
        var ss = add0(d.getSeconds());
        return `${YYYY}-${MM}-${DD} ${hh}:${mm}:${ss}`;
        return d;
    },
    
    // MD5Password 加密
    MD5Password (value) {
        const salt = bcrypt.genSaltSync(10);
        const  hash = bcrypt.hashSync(value,salt);
        return hash
    }
}